home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / frasr182.zip / MISCOVL.C < prev    next >
C/C++ Source or Header  |  1993-08-18  |  58KB  |  1,870 lines

  1. /*
  2.     Overlayed odds and ends that don't fit anywhere else.
  3. */
  4.  
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #ifndef XFRACT
  9. #include <process.h>
  10. #include <dos.h>
  11. #include <stdarg.h>
  12. #include <io.h>
  13. #else
  14. #include <varargs.h>
  15. #endif
  16. #include "fractint.h"
  17. #include "fractype.h"
  18. #include "helpdefs.h"
  19. #include "prototyp.h"
  20.  
  21. /* routines in this module    */
  22.  
  23. static void write_batch_parms(FILE *,char *,int);
  24. #ifndef XFRACT
  25. static void put_parm(char *parm,...);
  26. #else
  27. static void put_parm();
  28. #endif
  29.  
  30. static void put_parm_line(void);
  31. static int getprec(double,double,double);
  32. static void put_float(int,double,int);
  33. static void put_filename(char *keyword,char *fname);
  34. static void format_item(int choice,char *buf);
  35. static int check_modekey(int curkey,int choice);
  36. static int entcompare(VOIDCONSTPTR p1,VOIDCONSTPTR p2);
  37. static void update_fractint_cfg(void);
  38. extern int  debugflag;
  39. extern int  xdots,ydots;
  40. extern int  cpu;        /* cpu type            */
  41. extern int  fpu;        /* fpu type            */
  42. extern int  iit;        /* iit fpu?            */
  43. extern int  video_type;
  44. extern int  askvideo;
  45. extern char overwrite;        /* 1 means ok to overwrite */
  46. extern int  fillcolor;        /* fill color: -1 = normal*/
  47. extern int  inside;        /* inside color: 1=blue     */
  48. extern int  outside;        /* outside color, if set    */
  49. extern double xxmin,xxmax,yymin,yymax,xx3rd,yy3rd; /* selected screen corners */
  50. extern double sxmin, sxmax, sx3rd, symin, symax, sy3rd; /* zoom box corners */
  51. extern double param[];       /* up to four parameters    */
  52. extern int  finattract;     /* finite attractor option  */
  53. extern int  forcesymmetry;
  54. extern int  LogFlag;        /* non-zero if logarithmic palettes */
  55. extern int  rflag, rseed;
  56. extern int  periodicitycheck;
  57. extern int  potflag;        /* continuous potential flag */
  58. extern int  pot16bit;        /* save 16 bit values for continuous potential */
  59. extern double potparam[3];    /* three potential parameters*/
  60. extern int  fractype;        /* if == 0, use Mandelbrot  */
  61. extern BYTE usemag;
  62. extern long delmin;
  63. extern int  maxit;        /* try this many iterations */
  64. extern int  invert;        /* non-zero if inversion active */
  65. extern double inversion[];
  66. extern int  decomp[];
  67. extern int  distest;        /* non-zero if distance estimator   */
  68. extern int  distestwidth;
  69. extern int  init3d[20];     /* '3d=nn/nn/nn/...' values */
  70. extern char floatflag;        /* floating-point fractals? */
  71. extern int  usr_biomorph;
  72. extern char FormFileName[];    /* file to find (type=)formulas in */
  73. extern char FormName[];     /* Name of the Formula (if not null) */
  74. extern char LFileName[];
  75. extern char LName[];
  76. extern char IFSFileName[];
  77. extern char IFSName[];
  78. extern int  bailout;        /* user input bailout value */
  79. extern char useinitorbit;
  80. extern _CMPLX initorbit;
  81. extern int  display3d;        /* 3D display flag: 0 = OFF */
  82. extern int  overlay3d;        /* 3D overlay flag: 0 = OFF */
  83. extern int  loaded3d;
  84. extern char readname[];     /* name of fractal input file */
  85. extern int  showfile;        /* has file been displayed yet? */
  86. extern int  transparent[];
  87. extern char preview;        /* 3D preview mode flag */
  88. extern char showbox;        /* flag to show box and vector in preview */
  89. extern int  RANDOMIZE;        /* Color randomizing factor */
  90. extern int  Targa_Out;  /* Selects full color with light source fills */
  91. extern int  Ambient;        /* Darkness of shadows in light source */
  92. extern int  haze;        /* Amount of haze to factor in in full color */
  93. extern char light_name[];    /* Name of full color .TGA file */
  94. extern int previewfactor;
  95. extern int BRIEF;
  96. extern int RAY;
  97. extern int xtrans;
  98. extern int ytrans;
  99. extern int red_crop_left;
  100. extern int red_crop_right;
  101. extern int blue_crop_left;
  102. extern int blue_crop_right;
  103. extern int red_bright;
  104. extern int blue_bright;
  105. extern int xadjust;
  106. extern int eyeseparation;
  107. extern int glassestype;
  108. extern BYTE trigndx[];
  109. extern int rotate_lo,rotate_hi;
  110. extern int far *ranges;
  111. extern int rangeslen;
  112. extern char CommandFile[80];
  113. extern char CommandName[ITEMNAMELEN+1];
  114. extern char far CommandComment1[57];
  115. extern char far CommandComment2[57];
  116. extern char far CommandComment3[57];
  117. extern char far CommandComment4[57];
  118. extern char usr_stdcalcmode;
  119.  
  120. extern int calc_status;
  121. extern double    sxmin,sxmax,symin,symax,sx3rd,sy3rd;
  122.  
  123. /* Julibrot variables TIW 1/24/93 */
  124. extern double mxmaxfp, mxminfp, mymaxfp, myminfp, originfp;
  125. extern double depthfp, heightfp, widthfp, distfp, eyesfp;
  126.  
  127. extern int zdots; 
  128. extern int lastorbittype, neworbittype;
  129. extern char *juli3Doptions[];
  130. extern int juli3Dmode;
  131.  
  132. /* viewwindows parameters */
  133. extern int   viewwindow;
  134. extern float viewreduction;
  135. extern int   viewcrop;
  136. extern float finalaspectratio;
  137. extern int   viewxdots,viewydots;
  138.  
  139. extern int  colorstate;     /* comments in cmdfiles */
  140. extern int  colors;
  141. extern int  gotrealdac;
  142. extern int  reallyega;
  143. extern char colorfile[];
  144. extern int  mapset;
  145. extern char MAP_name[];
  146. extern BYTE dacbox[256][3];
  147. extern char far *mapdacbox;
  148. extern int save_release;
  149.  
  150. extern char tstack[4096];
  151. extern char s_cantopen[];
  152. extern char s_cantwrite[];
  153. extern char s_cantcreate[];
  154. extern char s_cantunderstand[];
  155. extern char s_cantfind[];
  156. extern int calc_status;
  157.  
  158. extern struct videoinfo far videotable[];
  159.  
  160. /* fullscreen_choice options */
  161. #define CHOICERETURNKEY 1
  162. #define CHOICEMENU    2
  163. #define CHOICEHELP    4
  164. void miscovl_overlay() { }    /* for restore_active_ovly */
  165.  
  166. extern char s_real[];
  167. extern char s_imag[];
  168. extern char s_mult[];
  169. extern char s_sum[];
  170. extern char s_zmag[];
  171. extern char s_bof60[];
  172. extern char s_bof61[];
  173. extern char s_maxiter[];
  174. extern char s_epscross[];
  175. extern char s_startrail[];
  176. extern char s_normal[];
  177. extern char s_period[];
  178.  
  179. char *major[] = {"breadth","depth","walk","run"};
  180. char *minor[] = {"left","right"};
  181.  
  182. static FILE *parmfile;
  183.  
  184. #define PAR_KEY(x)  ( x < 10 ? '0' + x : 'a' - 10 + x)
  185.  
  186. #ifdef C6
  187. #pragma optimize("e",off)  /* MSC 6.00A messes up next rtn with "e" on */
  188. #endif
  189. void make_batch_file()
  190. {
  191.    static char far hdg[]={"Save Current Parameters"};
  192.    /** added for pieces feature **/
  193.    double pdelx;
  194.    double pdely;
  195.    double pdelx2;
  196.    double pdely2;
  197.    unsigned int j, pxdots, pydots, xm, ym;
  198.    double pxxmin, pxxmax, pyymin, pyymax, pxx3rd, pyy3rd;
  199.    char vidmde[4];
  200.    int promptnum;
  201.    int piecespromts;
  202.    int have3rd;
  203.    /****/
  204.  
  205.    int i;
  206.    char inpcommandfile[80], inpcommandname[ITEMNAMELEN + 1];
  207.    char inpcomment1[57], inpcomment2[57], inpcomment3[57], inpcomment4[57];
  208.    struct fullscreenvalues paramvalues[18];
  209.    char far *choices[18];
  210.    int gotinfile;
  211.    char outname[81], buf[256], buf2[128];
  212.    FILE *infile;
  213.    FILE *fpbat=NULL;
  214.    char colorspec[14];
  215.    int maxcolor;
  216.    int maxcolorindex;
  217.    char *sptr, *sptr2;
  218.    int oldhelpmode;
  219.  
  220.    ENTER_OVLY(OVLY_MISCOVL);
  221.    stackscreen();
  222.    oldhelpmode = helpmode;
  223.    helpmode = HELPPARMFILE;
  224.  
  225.    strcpy(colorspec, "n");
  226.    maxcolor = colors;
  227.    if (gotrealdac && !reallyega)
  228.    {
  229.       --maxcolor;
  230. /*    if (maxit < maxcolor)  remove 2 lines */
  231. /*       maxcolor = maxit;   so that whole palette is always saved */
  232.       if (inside > 0 && inside > maxcolor)
  233.          maxcolor = inside;
  234.       if (outside > 0 && outside > maxcolor)
  235.          maxcolor = outside;
  236.       if (distest < 0 && 0 - distest > maxcolor)
  237.          maxcolor = 0 - distest;
  238.       if (decomp[0] > maxcolor)
  239.          maxcolor = decomp[0] - 1;
  240.       if (potflag && potparam[0] >= maxcolor)
  241.          maxcolor = potparam[0];
  242.       if (++maxcolor > 256)
  243.          maxcolor = 256;
  244.       if (colorstate == 0)
  245.       {                         /* default colors */
  246.          if (mapdacbox)
  247.          {
  248.             colorspec[0] = '@';
  249.             sptr = MAP_name;
  250.          }
  251.       }
  252.       else
  253.       if (colorstate == 2)
  254.       {                         /* colors match colorfile */
  255.          colorspec[0] = '@';
  256.          sptr = colorfile;
  257.       }
  258.       else                      /* colors match no .map that we know of */
  259.          colorspec[0] = 'y';
  260.       if (colorspec[0] == '@')
  261.       {
  262.          if ((sptr2 = strrchr(sptr, SLASHC)))
  263.             sptr = sptr2 + 1;
  264.          if ((sptr2 = strrchr(